﻿<helpers:PhonePageBase xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                       xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                       xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                       xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                       xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
                       xmlns:helpers="clr-namespace:Flowers.Helpers"
                       xmlns:ignore="http://www.galasoft.ch/ignore"
                       x:Class="Flowers.MainPage"
                       mc:Ignorable="d ignore"
                       SupportedOrientations="Portrait"
                       Orientation="Portrait"
                       shell:SystemTray.IsVisible="True"
                       DataContext="{Binding Main, Source={StaticResource Locator}}">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="FlowerViewModelTemplate">
            <Grid Height="123"
                  Margin="0,0,0,10"
                  Background="#00000000">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Tap">
                        <command:EventToCommand Command="{Binding Main.ShowDetailsCommand, Mode=OneWay, Source={StaticResource Locator}}"
                                                CommandParameter="{Binding Mode=OneWay}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>

                <Image Width="100"
                       Height="100"
                       VerticalAlignment="Top"
                       Source="{Binding ImageUri, Mode=OneWay}"
                       Grid.RowSpan="2"
                       Margin="0,5,12,0" />

                <TextBlock Text="{Binding Model.Name}"
                           Grid.Column="1"
                           FontSize="36"
                           Foreground="#FFFA28D4"
                           Margin="0,-5,0,0" />

                <TextBlock TextWrapping="Wrap"
                           Text="{Binding Model.Description}"
                           TextTrimming="WordEllipsis"
                           Grid.Row="1"
                           Grid.Column="1"
                           FontSize="18" />
            </Grid>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot"
          Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel"
                    Grid.Row="0"
                    Margin="12,17,0,28">
            <TextBlock Style="{StaticResource PhoneTextNormalStyle}"
                       Margin="12,0"
                       Text="{StaticResource ApplicationName}" />

            <TextBlock Text="all flowers"
                       Margin="9,-7,0,0"
                       Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <Button Content="refresh"
                Grid.Row="2"
                Command="{Binding RefreshCommand, Mode=OneWay}" />

        <Image Style="{StaticResource IconStyle}" />

        <ListBox ItemTemplate="{StaticResource FlowerViewModelTemplate}"
                 ItemsSource="{Binding Flowers}"
                 Grid.Row="1"
                 HorizontalContentAlignment="Stretch"
                 ItemContainerStyle="{StaticResource ListBoxItemStyle}"
                 Margin="24,0" />

        <TextBlock HorizontalAlignment="Left"
                   Text="{Binding LastLoadedFormatted, Mode=OneWay}"
                   VerticalAlignment="Bottom"
                   Foreground="White"
                   Margin="24,0,0,6"
                   FontSize="14" />
    </Grid>
</helpers:PhonePageBase>